#!/usr/local/bin/python3.6
#coding:utf-8
# @Time    : 2019/11/22 11:02
# @Author  : ZhangBing
# @Email   : 18829272841@163.com
# @File    : utls.py
# @Software: PyCharm
import  logging

def getlogger(mod_name,path:str='/var/log/blog'):
    getlog=logging.getLogger(mod_name)
    getlog.setLevel(logging.INFO)
    handler=logging.FileHandler('{}/{}.log'.format(path,mod_name))
    fmt=logging.Formatter("%(asctime)s [%(levelname)s] %(message)s (%(filename)s:L%(lineno)d)",
                            datefmt='%Y-%m-%d %H:%M:%S')
    handler.setFormatter(fmt)
    getlog.addHandler(handler)
    return   getlog

if __name__ == "__main__":
    log=getlogger('test')
    log.info('1234')
